import api from './index'

// 上传图片
export const uploadImage = (file) => {
  const formData = new FormData()
  formData.append('file', file)
  
  return api.post('file/upload/image', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 上传头像
export const uploadAvatar = (file) => {
  const formData = new FormData()
  formData.append('file', file)
  
  return api.post('file/upload/avatar', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 上传收款码
export const uploadQrCode = (file) => {
  const formData = new FormData()
  formData.append('file', file)
  
  return api.post('file/upload/qrcode', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 上传文档
export const uploadDocument = (file) => {
  const formData = new FormData()
  formData.append('file', file)
  
  return api.post('file/upload/document', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 通用文件上传
export const uploadFile = (file, folder = 'files/') => {
  const formData = new FormData()
  formData.append('file', file)
  formData.append('folder', folder)
  
  return api.post('file/upload', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 上传视频
export const uploadVideo = (file) => {
  const formData = new FormData()
  formData.append('file', file)
  
  return api.post('file/upload/video', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 删除文件
export const deleteFile = (fileUrl) => {
  return api.delete('file/delete', {
    params: { url: fileUrl }
  })
} 